package org.wzh.three.jvm.oom;

import java.util.ArrayList;
import java.util.List;

/**
 * Java 堆溢出
 * @author ewanhiz
 * VM Args: -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError
 */
public class HeapOOM {

    static class OOMObject {}

    public static void main(String[] args) {
        List<OOMObject> list = new ArrayList<>();

        int count = 0;
        while (true) {
            System.out.println(count++);
            list.add(new OOMObject());
        }
    }

}
